package com.my.study.common.security.account;

import com.my.study.common.security.AbstractCustomAuthenticationToken;
import com.my.study.dto.JwtUserDto;

/**
 * @author yidujun
 * @date 2022/8/3 17:30
 */
public class AccountAuthenticationToken extends AbstractCustomAuthenticationToken {
    private static final long serialVersionUID = -866862471910843217L;
    
    private String userName;
    private String password;
    
    public AccountAuthenticationToken(String userName, String password) {
        super(null);
        this.userName = userName;
        this.password = password;
        super.setAuthenticated(false);
    }
    
    public AccountAuthenticationToken(String userName, String password, 
                                      JwtUserDto jwtUserDto) {
        super(jwtUserDto.getAuthorities());
        this.userName = userName;
        this.password = password;
        this.jwtUserDto = jwtUserDto;
        super.setAuthenticated(true);
    }
    

    @Override
    public Object getCredentials() {
        return null;
    }

    @Override
    public Object getPrincipal() {
        return null;
    }

    @Override
    public void eraseCredentials() {
        super.eraseCredentials();
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String getName() {
        return userName;
    }
}
